package com.wangyi.im.enums;

import java.util.Arrays;

public class IMCodeEnum {

    public static enum IMCode{
        IM_200("200", "操作成功"),
        IM_201("201", "客户端版本不对，需升级sdk"),
        IM_301("301", "被封禁"),
        IM_302("302", "用户名或密码错误"),
        IM_315("315", "IP限制"),
        IM_403("403", "非法操作或没有权限"),
        IM_404("404", "对象不存在"),
        IM_405("405", "参数长度过长"),
        IM_406("406", "对象只读"),
        IM_408("408", "客户端请求超时"),
        IM_414("414", "参数错误"),
        IM_415("415", "客户端网络问题"),
        IM_416("416", "频率控制"),
        IM_417("417", "重复操作"),
        IM_419("419", "数量超过上限"),
        IM_422("422", "账号被禁用"),
        IM_431("431", "HTTP重复请求"),
        IM_500("500", "服务器内部错误"),
        IM_503("503", "服务器繁忙"),
        IM_508("508", "消息撤回时间超限"),
        IM_509("509", "无效协议"),
        IM_514("514", "服务不可用"),
        IM_998("998", "解包错误"),
        IM_999("999", "打包错误"),
        IM_000("000","未定义错误")
        ;
        public String code;

        public String desc;

        IMCode(String code, String desc){
            this.code = code;
            this.desc = desc;
        }

        public static IMCode getImCode(String code){
            return Arrays.stream(IMCode.values()).filter(imCode -> imCode.code.equals(code)).findFirst().orElse(IM_000);
        }
    }


}
